<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>创建对象三种方法</title>
</head>
<body>
    <script>
        //对象字面量
        //var obj = {}; //创建了一个空的对象
        var obj = {
            name: 'aaa',
            age: 'n',
            sex: 'sss',
            sayHi: function(){
                console.log("ASASASASAS");
            }
        }

        for(let i in obj){

        }

        var obb = {}
        obb.names = 'AAAAA';
        //属性或方法用键值对形式表示
        //多个属性方法用逗号隔开
        //方法名后跟一个匿名函数

        //使用对象
        obj.age;
        obj['age'];
        //调用对象方法
        obj.sayHi();
        console.log(obb.names);


        //new object创建对象
        var obj = new Object(); //创建了一个空对象
        obj.name = 'aaaa';
        obj.age = 'asdasda';
        obj.agww = 121212;
        obj.sayHi = function(){
            
            console.log("ASAAS");
            //每个属性和方法都用分号隔开
        }
    </script>
</body>
</html>